//
//  SettingViewController.m
//  UI_xiangmu
//
//  Created by dlios on 15-4-28.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "SettingViewController.h"
#import "LoginViewController.h"
#import "FeedbackViewController.h"
#import "OurViewController.h"

@interface SettingViewController ()

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self createSetView];
}

#pragma mark 创建视图
- (void)createSetView
{
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"设置";
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    backButton.frame = CGRectMake(300, 0, 50, 30);
    backButton.layer.borderWidth = 0.3;
    backButton.layer.cornerRadius = 8;
    backButton.backgroundColor = [UIColor whiteColor];
    [backButton setTitle:@"退出" forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:backButton] autorelease];

    //背景图片
    UIImage *image = [UIImage imageNamed:@"lufei.jpg"];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [imageView setImage:image];
    [self.view addSubview:imageView];
    [imageView release];
    
    //登陆Button
    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
    loginButton.frame = CGRectMake(100, 40, 175, 40);
    loginButton.layer.borderWidth = 0.1;
    loginButton.layer.cornerRadius = 8;
    loginButton.backgroundColor = [UIColor whiteColor];
    [loginButton setTitle:@"登陆" forState:UIControlStateNormal];
    [loginButton addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginButton];
    
    //夜间模式button
    UIButton *nightButton = [UIButton buttonWithType:UIButtonTypeSystem];
    nightButton.frame = CGRectMake(100, 100, 175, 40);
    nightButton.layer.borderWidth = 0.1;
    nightButton.layer.cornerRadius = 8;
    nightButton.backgroundColor = [UIColor whiteColor];
    [nightButton setTitle:@"夜间模式" forState:UIControlStateNormal];
    [nightButton addTarget:self action:@selector(nightAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:nightButton];
    
    //清除缓存button
    UIButton *clearButton = [UIButton buttonWithType:UIButtonTypeSystem];
    clearButton.frame = CGRectMake(100, 350, 175, 40);
    clearButton.layer.borderWidth = 0.1;
    clearButton.layer.cornerRadius = 8;
    clearButton.backgroundColor = [UIColor whiteColor];
    [clearButton setTitle:@"清除缓存" forState:UIControlStateNormal];
    [clearButton addTarget:self action:@selector(clearAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:clearButton];
    
    //用户反馈button
    UIButton *feedbackButton = [UIButton buttonWithType:UIButtonTypeSystem];
    feedbackButton.frame = CGRectMake(100, 410, 175, 40);
    feedbackButton.layer.borderWidth = 0.1;
    feedbackButton.layer.cornerRadius = 8;
    feedbackButton.backgroundColor = [UIColor whiteColor];
    [feedbackButton setTitle:@"用户反馈" forState:UIControlStateNormal];
    [feedbackButton addTarget:self action:@selector(feedbackAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:feedbackButton];
    
    //关于我们button
    UIButton *ourButton = [UIButton buttonWithType:UIButtonTypeSystem];
    ourButton.frame = CGRectMake(100, 470, 175, 40);
    ourButton.layer.borderWidth = 0.1;
    ourButton.layer.cornerRadius = 8;
    ourButton.backgroundColor = [UIColor whiteColor];
    [ourButton setTitle:@"关于我们" forState:UIControlStateNormal];
    [ourButton addTarget:self action:@selector(ourAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:ourButton];
}

#pragma mark 退出登陆点击方法
- (void)backAction
{
    NSLog(@"退出登陆");
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"您要离开我们的家吗?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
}

#pragma mark 登陆点击方法
- (void)loginAction
{
    NSLog(@"登陆");
    LoginViewController *loginVC = [[LoginViewController alloc] init];
    [self.navigationController pushViewController:loginVC animated:YES];
    [loginVC release];
}

#pragma mark 夜间模式点击方法
- (void)nightAction
{
    NSLog(@"转为夜间模式");
}

#pragma mark 清除缓存点击方法
- (void)clearAction
{
    NSLog(@"清除缓存");
}

#pragma mark 用户反馈点击方法
- (void)feedbackAction
{
    NSLog(@"用户反馈");
    FeedbackViewController *feedbackVC = [[FeedbackViewController alloc] init];
    [self.navigationController pushViewController:feedbackVC animated:YES];
    [feedbackVC release];
}

#pragma mark 关于我们点击方法
- (void)ourAction
{
    NSLog(@"关于我们");
    OurViewController *ourVC = [[OurViewController alloc] init];
    [self.navigationController pushViewController:ourVC animated:YES];
    [ourVC release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
